﻿
// 添加Log4net日志



using IotClientConsole.Services;
using IotClientService;
using Microsoft.Extensions.DependencyInjection;
using XT.Common.Config;
using XT.Common.Models.WinService;
using XT.Common.Services;
using XT.WinService;


    var services = new ServiceCollection();
    ShareService.ConfigureLog4net();

    services.AddSingleton(new AppSettings(false));

    ShareService.AddWinService(services);

    // window服务启动服务
    services.AddSingleton<IWindowService, ClientWinService>();

    services.RegisterClientService();
    services.RegisterClientGrpc();


    var serviceProvider = services.BuildServiceProvider();

    string ext = string.Empty;
    var location = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "-");
    var locations = location.Split("-").ToList();
    locations.RemoveAt(locations.Count - 1);


    if (locations.Count < 4)
    {
        ext = location;
    }
    else
    {
        ext = string.Join("-", locations.TakeLast(3));
    }

 
        ShareService.RunWinService(serviceProvider, new ServiceInfo
        {
            Description = "IotClientConsole服务",
            DisplayName = "IotClientConsole-" + ext,
            Name = "IotClientConsole-" + ext
        });
  

while (true)
{
    await Task.Delay(1000);
}






